class MinStack {
public:
    /** initialize your data structure here. */
    MinStack() {
        
    }
    //const int MAX_S=8001;
    int size1=0;
    int size2=0;
    //数组模拟栈
    int data[8001];  //数据
    int min[8001];   //最小
    void push(int val) {
        data[size1]=val;
        if(size2==0||val<=min[size2-1])
        {
            min[size2]=val;
            size2++;
        }
        size1++;
    }
    
    void pop() {
        if(data[size1-1]==min[size2-1])
        {
            size2--;
        }
        size1--;
    }
    
    int top() {
        return data[size1-1];
    }
    
    int getMin() {
        return min[size2-1];
    }
};

/**
 * Your MinStack object will be instantiated and called as such:
 * MinStack* obj = new MinStack();
 * obj->push(x);
 * obj->pop();
 * int param_3 = obj->top();
 * int param_4 = obj->getMin();
 */